package com.shb.game;

import android.app.TabActivity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TabHost;
import android.widget.TextView;

public class MainActivity extends TabActivity {
	private TabHost mTabHost;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
		setContentView(R.layout.main);
		mTabHost = getTabHost();
		createTab("巧猜数字", new Intent(this, GuessNumActivity.class));
		createTab("疯狂数字", new Intent(this, CrazyNumActivity.class));
		createTab("数字拼图", new Intent(this, PicNumActivity.class));
		createTab("记忆数字", new Intent(this, MemNumActivity.class));
		mTabHost.setCurrentTab(0);
	}

	private void createTab(String text, Intent intent) {
		TextView tv = new TextView(this);
		tv.setText(text);
		tv.setPadding(10, 10, 10, 10);
		tv.setGravity(Gravity.CENTER);
		tv.setBackgroundResource(R.drawable.btn_bg);
		tv.setTextColor(Color.BLACK);
		LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		lp.setMargins(2, 5, 2, 5);
		tv.setLayoutParams(lp);

		mTabHost.addTab(mTabHost.newTabSpec(text).setContent(intent).setIndicator(tv));
	}

}